/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package e.z.blog.back.com.impl;

import e.z.blog.back.com.ComNavTreeApi;
import java.util.HashMap;
import java.util.Map;
import org.nutz.ioc.loader.annotation.IocBean;
import z.h.w.jar.data.tree.ReferTree;
import z.h.w.jar.kit.To;

/**
 * 该类暂时输出固定的树，以后实现了权限管理后，就实现根据角色不同，分发不同的目录资源
 *
 * @author EnzoZhong
 */
@IocBean
public class ComNavTree implements ComNavTreeApi {

        /**
         * 暂时这是管理员的树目录，以后写了权限系统后，就根据权限不同分发不同的资源
         *
         * @return
         */
        @Override
        public ReferTree<Map<String , String>> getNavTree () {
                Map<String , String> ROOT = createMap( "ROOT" );
                ReferTree<Map<String , String>> tree = new ReferTree( ROOT );

                tree.add( To.objs2Array(
                        createMap( "首页" , "/back/index" , "_self" ) ,
                        createMap( "Blog操控" ) ,
                        createMap( "系统操控" ) ,
                        createMap( "退出" , "/back" , "_self" ) ) , ROOT );

                tree.add( To.objs2Array(
                        createMap( "语言管理" ) ,
                        createMap( "目录管理" ) ,
                        createMap( "标签管理" ) ,
                        createMap( "文章管理" ) ,
                        createMap( "留言管理" ) ) , createMap( "Blog操控" ) );

                tree.add( To.objs2Array(
                        createMap( "语言Crud" , "/back/lan" ) ) , createMap( "语言管理" ) );

                tree.add( To.objs2Array(
                        createMap( "目录Crud" , "/back/tab" ) ) , createMap( "目录管理" ) );

                tree.add( To.objs2Array(
                        createMap( "标签Crud" , "/back/tag" ) ) , createMap( "标签管理" ) );

                tree.add( To.objs2Array(
                        createMap( "文章Crud" , "/back/essay" ) ) , createMap( "文章管理" ) );

                tree.add( To.objs2Array(
                        createMap( "留言Crud" , "/back/remark" ) ) , createMap( "留言管理" ) );

                /*
                 * -----------------------------------------系统目录类--------------------------------------
                 */

                tree.add( To.objs2Array(
                        createMap( "模板管理" ) ) , createMap( "系统操控" ) );

                return tree;
        }

        /**
         *
         * @param name < p/>
         * <p/>
         * @return
         */
        public static Map<String , String> createMap ( String name ) {
                return createMap( name , "" , "" );
        }

        /**
         *
         * @param name param href
         * <p/>
         * @return
         */
        public static Map<String , String> createMap ( String name , String href ) {
                return createMap( name , href , "" );
        }

        /**
         *
         * @param name param href param target
         * <p/>
         * @return
         */
        public static Map<String , String> createMap ( String name , String href , String target ) {
                Map<String , String> re = new HashMap();
                re.put( "name" , name );
                re.put( "url" , href );
                if ( target.equalsIgnoreCase( "" ) ) {
                        re.put( "target" , "myFrame" );
                } else {
                        re.put( "target" , target );
                }
                return re;
        }
}
